// pages/home/index.js
const netWorked = require('../../utils/netWork.js')
Page({

     /**
      * 页面的初始数据
      */
     data: {
          list:[
               {
                    id:1,
              img:'../../images/首页/BOOKMARKING SERVICES.png',
                    text:"档案管理"
               },
               {
                    id: 2,
                 img: '../../images/首页/PICTURE OPTIMIZATION.png',
                    text: "新品管理"
               },
               {
                    id: 3,
                 img: '../../images/首页/INS-STORE PROMOTIONS.png',
                    text: "采购管理"
               },
               {
                    id: 4,
                 img: '../../images/首页/PR & COMMUNICATION.png',
                    text: "批发管理"
               },
               {
                    id: 5,
                 img: '../../images/首页/E-COMMERCE SOLUTIONS.png',
                    text: "订货管理"
               },
              //  {
              //       id: 6,
              //    img: '../../images/首页/KEYWORD ANALYSIS (1).png',
              //       text: "库存管理"
              //  },
               {
                    id: 7,
                 img: '../../images/首页/LINK BUILDING.png',
                    text: "系统管理"
               },
               {
                    id: 8,
                 img: '../../images/首页/AFFILIATE MARKETING.png',
                    text: "全部管理"
               },
          ],
          goodsImg:[]
     },
     goShech(e){
          let indextof = e.currentTarget.dataset.index
          if (indextof==7){
               wx.navigateTo({
                    url: '/pages/management/all/index'
                    
               })
          }else{
               wx.navigateTo({
                    url: '/pages/management/record/index?indextof=' + indextof
               })
          }
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
          let id = wx.getStorageSync("role_id")
          let that = this 
       let goodsImg1 = []
       let goodsImg2=[]
       let goodsImg3=[]
       let goodsImg4 = []
       let goodsImg5 = []
       let goodsImg6 = []
       let goodsImg7 = []
          
          netWorked.netWork({
            url: 'System/SelMenu?role_id=' + 0 +'&wxIsShow=1',
               method: "POST",
               success: function (res) {
                   that.setData({
                        goodsImg: res.data
                   })
                //  console.log(that.data.goodsImg)
                    let goodsImg = that.data.goodsImg
                    for(let i in goodsImg){
                      if (goodsImg[i].Superiorid==1000){
                        goodsImg1.push({ name:goodsImg[i]})
                      } else if (goodsImg[i].Superiorid == 2000){
                        goodsImg2.push({ name: goodsImg[i] })
                      } else if (goodsImg[i].Superiorid == 3000) {
                        goodsImg3.push({ name: goodsImg[i] })
                      } else if (goodsImg[i].Superiorid == 4000) {
                        goodsImg4.push({ name: goodsImg[i] })
                      } 
                        //else if (goodsImg[i].Superiorid == 5000) {
                      //   goodsImg5.push({ name: goodsImg[i] })
                      // } 
                      
                      else if (goodsImg[i].Superiorid == 6000) {
                        goodsImg6.push({ name: goodsImg[i] })
                      } 
                      
                      else if (goodsImg[i].Superiorid == 7000){
                        goodsImg7.push({ name: goodsImg[i] })
                      }
                    }
                    wx.setStorageSync('goodsImg1', goodsImg1)
                //  console.log(wx.getStorageSync('goodsImg1'))
                    // 档案管理
                    wx.setStorageSync('goodsImg2', goodsImg2)
                    //新品管理
                    wx.setStorageSync('goodsImg3', goodsImg3)
                    //采购管理
                    wx.setStorageSync('goodsImg4', goodsImg4)
                    //批发管理
                    wx.setStorageSync('goodsImg5', goodsImg5)
                    //库存管理
                    wx.setStorageSync('goodsImg6', goodsImg6)
                    //系统管理
                    wx.setStorageSync('goodsImg7', goodsImg7)
                    //订货管理
               }
          })
          
          
     },

     /**
      * 生命周期函数--监听页面初次渲染完成
      */
     onReady: function () {

     },

     /**
      * 生命周期函数--监听页面显示
      */
     onShow: function () {

     },

     /**
      * 生命周期函数--监听页面隐藏
      */
     onHide: function () {

     },

     /**
      * 生命周期函数--监听页面卸载
      */
     onUnload: function () {

     },

     /**
      * 页面相关事件处理函数--监听用户下拉动作
      */
     onPullDownRefresh: function () {

     },

     /**
      * 页面上拉触底事件的处理函数
      */
     onReachBottom: function () {

     },

     /**
      * 用户点击右上角分享
      */
     onShareAppMessage: function () {

     }
})